import React, { useState, useEffect } from 'react'
import '../../assets/css/contract/Newrenewal.css'
import { inject, observer } from 'mobx-react'
function Newrenewal(props) {

    const [end_date, setend_date] = useState('')
    const [total_amount, settotal_amount] = useState('')
    const [received, setreceived] = useState('')
    const [user_name, setuser_name] = useState('')
    const [remarks, setremarks] = useState('')
    // contract_no: record.contract_no,
    // end_date: record.end_date,
    // entry_time: record.entry_time,
    // received: record.received,
    // remarks: record.remarks,
    // renewal_record: record.renewal_record,
    // total_amount: record.total_amount,
    // user_name: record.user_name,
    console.log(props.contractStore.feedlist);

    useEffect(() => {
        props.contractStore.feedlist = {
            contract_no: props.contractStore.feedlist.contract_no,
            entry_time: props.contractStore.feedlist.entry_time,
            end_date,
            total_amount,
            received,
            user_name,
            remarks,
            renewal_record: '111'
        }
    }, [])
    const changeenddate = (e) => {
        setend_date(e.target.value)
    }

    const changetotalamount = (e) => {
        settotal_amount(e.target.value)
    }
    const changereceived = (e) => {
        setreceived(e.target.value)
    }
    const changeusername = (e) => {
        setuser_name(e.target.value)
    }
    const changeremarks = (e) => {
        setremarks(e.target.value)
    }
    return (
        <div className='newrenewal'>
            <div><span>合同编号</span><input type="text" defaultValue={props.contractStore.feedlist.contract_no} /></div>
            <div>
                <span>起始日期</span><input type="text" defaultValue={props.contractStore.feedlist.entry_time} />
                <span>到期日期</span><input type="text" defaultValue={props.contractStore.feedlist.end_date} />
            </div>
            <div>
                <span>总金额</span><input type="text" defaultValue={props.contractStore.feedlist.total_amount} />
                <span>已收款</span><input type="text" defaultValue={props.contractStore.feedlist.received} />
            </div>
            <div><span>新到期日期</span><input type="text" value={end_date} onChange={(e) => { changeenddate(e) }} /><span>更新合同到期日期时间</span></div>
            <div>
                <span>总金额</span><input type="text" value={total_amount} onChange={(e) => { changetotalamount(e) }} />
                <span>已收款</span><input type="text" value={received} onChange={(e) => { changereceived(e) }} />
            </div>
            <div><span>备注</span><input type="text" value={remarks} onChange={(e) => { changeremarks(e) }} /></div>
            <div><span>业务员</span><input type="text" value={user_name} onChange={(e) => { changeusername(e) }} /></div>
        </div>
    )
}
export default inject('contractStore')(observer(Newrenewal))